package models

import "time"

// Role represents user role
type Role string

const (
	RoleViewer     Role = "viewer"
	RoleOperator   Role = "operator"
	RoleAdmin      Role = "admin"
	RoleSuperAdmin Role = "super_admin"
)

// UserStatus represents user status
type UserStatus string

const (
	UserStatusActive    UserStatus = "active"
	UserStatusInactive  UserStatus = "inactive"
	UserStatusSuspended UserStatus = "suspended"
)

// User represents a user in the system
type User struct {
	ID             string     `bson:"_id,omitempty" json:"id"`
	Username       string     `bson:"username" json:"username"`
	Email          string     `bson:"email" json:"email"`
	PasswordHash   string     `bson:"passwordHash" json:"-"` // Never expose password hash
	FullName       string     `bson:"fullName" json:"fullName"`
	AvatarURL      string     `bson:"avatarUrl,omitempty" json:"avatarUrl,omitempty"`
	Role           Role       `bson:"role" json:"role"`
	Status         UserStatus `bson:"status" json:"status"`
	CreatedAt      time.Time  `bson:"createdAt" json:"createdAt"`
	UpdatedAt      time.Time  `bson:"updatedAt" json:"updatedAt"`
	LastLoginAt    *time.Time `bson:"lastLoginAt,omitempty" json:"lastLoginAt,omitempty"`
	RefreshToken   string     `bson:"refreshToken,omitempty" json:"-"` // Store refresh token hash
}

// RefreshToken represents a refresh token
type RefreshToken struct {
	ID        string    `bson:"_id,omitempty" json:"id"`
	UserID    string    `bson:"userId" json:"userId"`
	Token     string    `bson:"token" json:"token"` // Store hashed token
	ExpiresAt time.Time `bson:"expiresAt" json:"expiresAt"`
	CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
}
